var xmlhttp;
//ajax 异步调用
function loadXMLDocAsyn(url, cfunc) {
	if (window.XMLHttpRequest) {
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp = new XMLHttpRequest();
	} else {
		// code for IE6, IE5
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange = cfunc;
	xmlhttp.open("GET", url, true);
	xmlhttp.send();
}

//ajax 同步调用
function loadXMLDocSyn(url) {
	if (window.XMLHttpRequest) {
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp = new XMLHttpRequest();
	} else {
		// code for IE6, IE5
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.open("GET", url, false);
	xmlhttp.send();
	return xmlhttp.status;
}

//复选框全选、不选切换
function checkChg(allId,subName) {
    var subIds = document.getElementsByName(subName);
    //全选
	if(document.getElementById(allId).checked==true){
	    for (var j = 0; j < subIds.length; j++) {
	        if (subIds.item(j).checked == false) {
	        	subIds.item(j).checked = true;
	        }
	    }
	}else{//全部选
	    for (var j = 0; j < subIds.length; j++) {
	        if (subIds.item(j).checked == true) {
	        	subIds.item(j).checked = false;
	        }
	    }
	}

}

//获取分页输入框里传来的页数,并根据页数，跳转到相应的页面
function getPage(page){
	if(page.length==0){
		alert("请输入要前往的页数");
		return false;
	}else{
		return page;
	}
}

//获取选择的数据的ID串(返回逗号分隔的id串)
function getSelectIds(subName){
	var str="";  
	var sel=document.getElementsByName(subName);//获取checkbox的值  
	for( var i=0;i<sel.length;i++){
		if(sel[i].checked==true)  
			str+=sel[i].value+",";
	}
	str = str.substring(0,str.length-1);//去掉最右边的","
	if(str==""){  
		alert("请至少选择一条记录");  
		return false; 
	}else{
		return str;
	}
}
//返回选中数据的唯一ID
function getSelectId(subName) { 
	var id=""; 
    var sel = document.getElementsByName(subName);   
    var checkCount = 0;  
    for (var i=0; i < sel.length; i++) {  
        if (sel[i].checked==true) {  
        	checkCount++;
        	id=sel[i].value;
        }  
    }  
    if (checkCount == 0) {  
        alert("请选择一个会员！");  
        return false;  
    } else if (checkCount > 1) {  
        alert("只能选择一个会员！");  
        return false;  
    } else {   
        return id;  
    }  
}  
